<template>
  <a-breadcrumb class="breadcrumb">
    <template v-for="(item, index) in breadList">
      <a-breadcrumb-item :key="item.name" v-if="!item.meta.hiddenBreadcrumb || item.meta.hiddenBreadcrumb == undefined">
        <router-link
          v-if="item.name != name && index != 1"
          :to="{ path: item.path === '' ? '/' : item.path }"
        >{{ item.meta.title }}
        </router-link>
        <span v-else>{{ item.meta.title }}</span>
      </a-breadcrumb-item>
    </template>
  </a-breadcrumb>
</template>
<script>
export default {
  data() {
    return {
      name: '',
      breadList: [],
    };
  },
  created() {
    this.getBreadcrumb();
  },
  methods: {
    getBreadcrumb() {
      this.breadList = [];
      // this.breadList.push({name: 'index', path: '/dashboard/', meta: {title: '首页'}})

      this.name = this.$route.name;
      this.$route.matched.forEach((item) => {
        // item.name !== 'index' && this.breadList.push(item)
        this.breadList.push(item);
      });
    },
  },
  watch: {
    $route() {
      this.getBreadcrumb();
    },
  },
};
</script>
<style lang="stylus" scoped>
</style>
